<extend name="Base/base" />
<block name='head'>
    <link rel="stylesheet" href="/Public/Admin/css/personal.css"/>、
    <link rel="stylesheet" href="/Public/Admin/css/style.css"/>
    <!--文件上传-->
    <script type="text/javascript" src="/Public/Cropper/js/ajaxfileupload.js" ></script>
    <style>
        #upload{background:url(/Public/Admin/images/file.png) no-repeat left center;padding-left:20px;padding-bottom:20px;display: inline-block;height: 38px;line-height: 38px;}
        .layui-form-item .title{font-size: 14px;font-weight: bold;border-bottom: 2px solid #2299ee;display: block;padding-bottom: 6px}
    </style>
</block>
<block name="content"> 
    <section class="layui-larry-box">
        <div class="larry-personal">
            <div class="layui-tab inputArea">
                <blockquote class="layui-elem-quote news_search">
                    <div class="layui-inline">
                        <a class="layui-btn layui-btn-normal newsAdd_btn" href="{:U('Flow/flowDesign',array('flow_id'=>$flow_id,'form_id'=>$form_id))}">返回</a>
                    </div>
                </blockquote>

                <!-- 表单项 -->
                <form class="layui-form" action="">
                    <div class="layui-form-item">
                        <span class="title">{$info.flow_name|default="新流程"} - 基本属性</span>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="c-red">*</span>流程名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="flow_name" class="layui-input" value="{$info.flow_name}">
                            <span class="errMsg"></span>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="c-red">*</span>流程分类</label>
                        <div class="layui-input-block">
                            <select name="flow_sort" class="layui-input" lay-verify="required">
                                <option value="0">请选择流程分类</option>
                                <foreach name="flowTypes" item="sort">
                                    <option value="{$sort.sort_id}" {$info['flow_sort'] == $sort['sort_id'] ? 'selected' :''}>{$sort.sort_name}</option>
                                </foreach>
                            </select>
                            <span class="errMsg"></span>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="c-red">*</span>表单</label>
                        <div class="layui-input-block">
                            <select name="form_id" class="layui-input" lay-verify="required">
                                <option value="0">请选择关联表单</option>
                                <foreach name="forms" item="form">
                                    <option value="{$form.form_id}" {$info['form_id'] == $form['form_id'] ? 'selected' :''}>{$form.form_name}</option>
                                </foreach>
                            </select>
                            <span class="errMsg"></span>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">流程排序</label>
                        <div class="layui-input-block">
                            <input type="text" name="flow_no" class="layui-input" value="{$info.flow_no}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">是否允许上传附件</label>
                        <div class="layui-input-block flow_doc">
                            <lable class="input_lable">
                                <input name="flow_doc" type="radio" id="sex-1" value="1" {$info['flow_doc'] == 1 ? 'checked' :''}>
                                <label for="sex-1">是</label>
                            </lable>
                            <lable class="input_lable">
                                <input type="radio" id="sex-2" value="0" name="flow_doc" {$info['flow_doc'] == 0 ? 'checked' :''}>
                                <label for="sex-2">否</label>
                            </lable>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">流程说明</label>
                        <div class="layui-input-block">
                            <textarea class="layui-input" name="flow_desc">{$info.flow_desc}</textarea>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">说明文档</label>
                        <div class="layui-input-block">
                            <div class="fujian">
                                <div class="filename-cont">
                                    <if condition="$info['uploads'] neq null">
                                        <span style="line-height: 38px">
                                            <a href="{$info.uploads_url}" download="{$info.uploads}">{$info.uploads}</a><img src="/Public/Index/img/close.png" style="width:15px" class="pointer delfile" data-fileurl="{$upload.url}">; 
                                        </span>
                                        <else/>
                                        <a href="#" id="upload"><span class="fj">上传说明文档</span></a>
                                        <div class="filename-cont"></div>
                                    </if>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <span class="title">{$info.flow_name|default="新流程"} - 移动端设置</span>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">是否首页显示</label>
                        <div class="layui-input-block level">
                            <lable class="input_lable">
                                <input name="is_show" type="radio" id="show-1" value="1" {$info['is_show'] == 1 ? 'checked' :''}>
                                <label for="show-1">是</label>
                            </lable>
                            <lable class="input_lable">
                                <input type="radio" id="show-2" value="0" name="is_show" {$info['is_show'] == 0 ? 'checked' :''}>
                                <label for="show-2">否</label>
                            </lable>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">图标编码</label>
                        <div class="layui-input-block">
                            <input type="text" name="icon" class="layui-input" value="{$info.icon}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">图标颜色</label>
                        <div class="layui-input-block">
                            <input type="text" name="color" class="layui-input" value="{$info.color}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block button">
                            <a class="layui-btn btn-submit ajax-post" data-url="{:U('newFlow')}" data-form="">提交</a>
                            <!--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
                        </div>
                    </div>
                    <input type="hidden" name="flow_id" value="{$info.flow_id}">
                    <input type="file" id="inputImage" name='imgfile' style="display:none">
                    <input type="hidden" id="filename" name="uploads" value="{$uploads[0].uploadsName}">
                    <input type="hidden" id="fileurl" name="uploads_url" value="{$uploads[0].uploadsUrl}">
                    <input type="hidden" name="url" value="{:U('delFile')}">
                </form>
                <!-- 完 -->
            </div>
        </div>
    </section>
</block>
<block name="script">
    <script type="text/javascript">
        //检查表单
        var flag = true;
        $('input[name=prcs_id]').on('blur', function () {
            var num = parseInt($(this).val());
            if (isNaN(num) || $(this).val() == '') {
                var msg = '步骤号必填且为整数！'
                $(this).next().text(msg);
                $('.ajax-post').removeClass('btn-submit');
            } else {
                $(this).next().text('');
                $('.ajax-post').addClass('btn-submit');
            }
        })
        $('input[name="prcs_name"]').on('blur', function () {
            if ($('input[name="prcs_name"]').val() == '') {
                var msg = '请填写步骤名称！'
                $('input[name="prcs_name"]').next().text(msg);
                flag = false;
            } else {
                $(this).next().text('');
            }
        })
        $('.ajax-post').on('click', function () {
            var flag = true;
            if ($('input[name="flow_name"]').val() == '') {
                var msg = '流程名称不能为空！'
                $('input[name="flow_name"]').next().text(msg);
                flag = false;
            } else {
                $(this).next().text('');
            }
            
            if($('select[name=flow_sort]').val() == 0){
                var msg = '请选择流程分类！'
                $('select[name="flow_sort"]').next().text(msg);
                flag = false;
            }else{
                $(this).next().text('');
            }
            
            if($('select[name=form_id]').val() == 0){
                var msg = '请选择关联表单！'
                $('select[name="form_id"]').next().text(msg);
                flag = false;
            }else{
                $(this).next().text('');
            }

            if (flag == false) {
                $(this).removeClass('btn-submit');
            } else {
                $(this).addClass('btn-submit');
            }
        })
    </script>    
    <script type="text/javascript" src="/Public/Admin/js/common.js"></script>
    <script type="text/javascript">
        $(initUpload("{:U(CONTROLLER_NAME.'/upload')}"));
    </script>
</block>
